﻿using System.Data;
using SqlSugar;
using 请求响应加密.Models.SqlSugarDemo;

namespace 请求响应加密.DAL
{
    public class Repository : IRepository
    {
        private Action<string, SugarParameter[]> LogAction;

        public Repository(ConnectionConfig config, Action<string, SugarParameter[]> logAction) : base(config)
        {
            this.LogAction = logAction;
            base.Aop.OnLogExecuting = LogAction;
        }

        public Repository(List<ConnectionConfig> configs, Action<string, SugarParameter[]> logAction) : base(configs)
        {
            this.LogAction = logAction;
            base.Aop.OnLogExecuting = LogAction;
        }

        public override void ChangeConnection(string configId)
        {
            base.ChangeDatabase(configId);
            base.Aop.OnLogExecuting = LogAction;
        }

        public override void Insert<T>(T model)
        {
            base.InsertableByObject(model).ExecuteCommand();
        }
    }
}
